#!/usr/bin/env python
#-*- coding:utf8 -*-
import os
import sys
import web
from config import routes, environment
from lib import quests
h  = "===============================\n"
h += "命令帮助:\n"
h += "site 命令类型入口\n"
h += "site 1 检测域名CNAME\n"
h += "site 2 更新网站配置数据至节点\n"
h += "site 3 删除节点对应网站\n"
h += "```````````````````````````````\n"
h += "node 1 新添加节点\n"
h += "node 2 检测节点状态\n"
h += "node 3 获取节点流量信息\n"
h += "```````````````````````````````\n"
h += "traffic 1 获取每个节点10分钟内流量\n"
h += "traffic 2 每个网站1个小时所有节点流量\n"
h += "traffic 3 统计所有站点24小时内流量\n"
h += "```````````````````````````````\n"
h += "check 1 每5分钟检测一次所有节点\n"
h += "check 2 每10分钟检测一次网站状态\n"
h += "check 3 每10分钟检测异常节点是否恢复\n"
h += "==============================="
def main(args):
    quest   = quests.Quests()
    root    = os.getcwd()
    _step   = ['1','2','3']
    try:
        step = args[1]
    except:
        sys.exit(h)
    if step not in _step:
        sys.exit(h)
    if args[0] == 'site':
        quest.sites(int(step))
    elif args[0] == 'node':
        quest.nodes(int(step))
    elif args[0] == 'traffic':
        quest.traffics(int(step))
    elif args[0] == 'check':
        quest.check(int(step))
if __name__ == '__main__':
    if len(sys.argv) > 1:
        main(sys.argv[1:])
    else:
        sys.exit(h)
